#include "fx_flanger.h"
#include "ui_fx_flanger.h"

fx_flanger::fx_flanger(QWidget *parent) :
    fx_basic(parent),
    ui(new Ui::fx_flanger)
{
    ui->setupUi(this);

    QStringList wave_form;
    wave_form << "Triangle" << "Sine";
    ui->comboBox_wave->addItems(wave_form);
    ui->comboBox_wave->setCurrentIndex(1);

    QStringList phase;
    phase << "-180" << "-90" << "0" << "90" << "180";
    ui->comboBox_phase->addItems(phase);
    ui->comboBox_phase->setCurrentIndex(2);
}

fx_flanger::~fx_flanger()
{
    delete ui;
}

void fx_flanger::ratio(int value)
{
    ui->label_8->setText(QString::number(value));
}

void fx_flanger::by(int  value)
{
    ui->label_9->setText(QString::number(value));
}

void fx_flanger::of(int value)
{
    ui->label_10->setText(QString::number(value));
}

void fx_flanger::freq(int value)
{
    ui->label_11->setText(QString::number(double(value) / 100));
}

void fx_flanger::num(int value)
{
    ui->label_12->setText(QString::number(value) + " ms");
}

void fx_flanger::addFX()
{
    BASS_DX8_FLANGER* result = new BASS_DX8_FLANGER();
    result->fDelay = ui->horizontalSlider_num->value();
    result->fDepth = ui->horizontalSlider_by->value();
    result->fFeedback = ui->horizontalSlider_of->value();
    result->fFrequency = ui->horizontalSlider_freq->value();
    result->fWetDryMix = ui->horizontalSlider_ratio->value();

    result->lWaveform = ui->comboBox_wave->currentIndex();
    int index = ui->comboBox_phase->currentIndex();
    if (index == 0)
        result->lPhase = BASS_DX8_PHASE_NEG_180;
    else if (index == 1)
        result->lPhase = BASS_DX8_PHASE_NEG_90;
    else if (index == 2)
        result->lPhase = BASS_DX8_PHASE_ZERO;
    else if (index == 3)
        result->lPhase = BASS_DX8_PHASE_90 ;
    else
        result->lPhase = BASS_DX8_PHASE_180;
    emit apply(BASS_FX_DX8_FLANGER, result);
}
